package com.CampaignManager.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("serial")
public class UnitTypeDTO implements Serializable {

	private Long id;	
	private String name;
	private Long fieldAllowance;
	private Long minPoints;
	private Long maxPoints;
	private String href;
	private String attached;
	private String faction;
	private String modelType;
	
	private List<ResourceAmountDTO> resources;
	public List<ResourceAmountDTO> getResources() {
		if (resources == null) resources = new ArrayList<ResourceAmountDTO>();
		return resources;
	}
	
	public String getModelType() {
		return modelType;
	}
	public void setModelType(String modelType) {
		this.modelType = modelType;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Long getFieldAllowance() {
		return fieldAllowance;
	}
	public void setFieldAllowance(Long fieldAllowance) {
		this.fieldAllowance = fieldAllowance;
	}
	public Long getMinPoints() {
		return minPoints;
	}
	public void setMinPoints(Long minPoints) {
		this.minPoints = minPoints;
	}
	public Long getMaxPoints() {
		return maxPoints;
	}
	public void setMaxPoints(Long maxPoints) {
		this.maxPoints = maxPoints;
	}
	public String getHref() {
		return href;
	}
	public void setHref(String href) {
		this.href = href;
	}
	public String getAttached() {
		return attached;
	}
	public void setAttached(String attached) {
		this.attached = attached;
	}
	public String getFaction() {
		return faction;
	}
	public void setFaction(String faction) {
		this.faction = faction;
	}
	
	public boolean isMerc(String playerFaction) {
		
		if (this.getFaction().equals(playerFaction))
			return false;
		
		if (this.getFaction().equals("Both") && (playerFaction.equals("Ord") ||
												 playerFaction.equals("Llael"))) {
			return false;			
		}
		return true;
	}
	
	public List<ResourceAmountDTO> getPurchaseCost(String faction) {
		
		boolean isMerc = this.isMerc(faction);
		if (isMerc) {
			List<ResourceAmountDTO> racs = new ArrayList<ResourceAmountDTO>();			
			ResourceAmountDTO r = new ResourceAmountDTO();
			r.setResource("Gold");
			r.setAmount(this.getMinPoints()*10);
			racs.add(r);
			return racs;
		} else {
			return this.getResources();			
		}		 
	}
}
